package com.university.mentalhealthplatform.teacherV2.service;

import com.university.mentalhealthplatform.appModels.Test;
import com.university.mentalhealthplatform.teacherV2.repository.TestRepositoryV2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class TestServiceV2 {

    @Autowired
    private TestRepositoryV2 testRepository;

    public List<Test> findAll() {
        return testRepository.findAll();
    }

    public Optional<Test> findById(Integer id) {
        return testRepository.findById(id);
    }

    public Test save(Test test) {
        return testRepository.save(test);
    }

    public void deleteById(Integer id) {
        testRepository.deleteById(id);
    }

    public List<Test> searchByTopic(String keyword) {
        return testRepository.findByTopicContaining(keyword);
    }
}